//
//  BottomView.m
//  MyNewWeiBo
//
//  Created by wpapple on 16/6/4.
//  Copyright © 2016年 heron. All rights reserved.
//

#import "BottomView.h"

@implementation BottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    [self addButtonwithImageName:@"compose_toolbar_picture" hightImageName:@"compose_toolbar_picture_highlighted"];
    [self addButtonwithImageName:@"compose_mentionbutton_background" hightImageName:@"compose_mentionbutton_background_highlighted"];
    [self addButtonwithImageName:@"compose_trendbutton_background" hightImageName:@"compose_trendbutton_background_highlighted"];
    [self addButtonwithImageName:@"compose_emoticonbutton_background" hightImageName:@"compose_emoticonbutton_background_highlighted"];
    [self addButtonwithImageName:@"compose_addbutton_background" hightImageName:@"compose_addbutton_background_highlighted"];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self setBackgroundColor:[UIColor whiteColor]];
    
    int i = 0;
    for (UIButton * btn in self.subviews) {
        CGFloat btnW = self.width / 5;
        CGFloat btnH = self.height;
        CGFloat btnY = 0;
        CGFloat btnX = btnW * i;
        i++;
        btn.frame = CGRectMake(btnX, btnY, btnW, btnH);
    }
}

- (void)addButtonwithImageName:(NSString *)imageName hightImageName:(NSString *)hightImageName{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:hightImageName] forState:UIControlStateHighlighted];
    [self addSubview:btn];
}

@end
